<?php

namespace app\admin\controller\order;

use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\CheckUtil;
use app\admin\model\UM as UM;
use app\admin\service\SubsidyStatisticsService;
use think\APP;
use think\Request as Request;

/**
 * SubsidyStatistics 控制器
 * Class SubsidyStatistics
 * @package app\admin\controller\order;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\admin\validate\order\SubsidyStatistics
 */
class SubsidyStatistics
{
    // 请求参数
    private Request $request;

    // service
    private SubsidyStatisticsService $service;

    public function __construct(Request $request, SubsidyStatisticsService $subsidyStatisticsService)
    {
        $this->request = $request;
        $this->service = $subsidyStatisticsService;
    }

    /**
     * 详情
     * @param UM|null $user
     * @return ApiResponse
     * @url /order/subsidy_statistics/read
     */
    public function read(?UM $user): ApiResponse
    {
        $request     = $this->request;

        $provinceId = $request->param('provinceId');
        $cityId = $request->param('cityId');
        $categoryId = $request->param('categoryId');
        $serverId = $request->param('serverId');
        $startTime = $request->param('startTime');
        $endTime = $request->param('endTime');
        $kw = $request->param('kw');

        return ApiResponse::success($this->service->read($user, $provinceId, $cityId, $categoryId, $serverId, $startTime, $endTime, $kw));
    }
}
